-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move badger, tests and benchmarks to sub-modules #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @muXxer 👋🏻 Love to see your interest in the SMT!
Before I do a full review I have a few higher level requests. I like the idea of removing the badgerDB
dependency by introducing a submodule. However I think moving the benchmarks and tests into submodules isn't the right move.
This approach forces a lot of methods to be exposed that we don't need to be exposed.
I think re-introducing the SimpleMap
and having the MapStore
conform to the same interface we use with badger would be ideal. The methods on the interface related to backups and restoration would be no-op but this would allow users to use either a simple go map type or the badger db for a more production use case.
So what do you think of moving the benchmarks and tests back into the main package, unexporting the methods that were changed and replacing the tests usage of badger with the MapStore
(this can be copy pasted from older versions probably with little changes)? This way we can still keep unexposed numerous methods that don't need to be exposed publicly, and also remove the dependency on badger for those that dont want it, while still keeping a builtin kvstore.
Firstly, love the idea of removing the explicit dependency on badger as I think it'd be nice to experiment & explore with stores likes +1 to @h5law's suggestion, so let us know what you think. @muXxer Also, we have other plans/ideas for features we want to add (e.g. making the smt support |
Hi @h5law and @Olshansk, @h5law to you suggestion, I actually thought exactly the same when I did these changes. Exporting all the functions just because of the tests and benchmarks is quite ugly, and a map implementation would be nicer indeed. But I was in a rush when I did that, and I thought it's good to get some feedback first. 😅 I can try to do it the way you said 👍 Actually, we already have another |
f372fc5
to
84d8fcc
Compare
84d8fcc
to
35cb503
Compare
@h5law done! I reverted all exposures of the internal smt methods. Some things to consider:
|
|
||
type badgerKVStore struct { | ||
db *badger.DB | ||
last_backup uint64 // timestamp of the most recent backup | ||
} | ||
|
||
var badgerToSMTErrorsMap = map[error]error{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some quick comments explaining this map and the conversion function in the godoc format
|
||
go 1.20 | ||
|
||
replace github.com/pokt-network/smt => ../../ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace github.com/pokt-network/smt => ../../ |
Saw your comment, if we remove this, now I have enabled CI for this PR lets see what happens. I can always prepare a follow up PR that is based off this that we ultimately merge in instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to remove the line and update to the correct commit in your follow up PR, which should be merged directly after this one.
"encoding/hex" | ||
"fmt" | ||
"io" | ||
"slices" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires go 1.21 - might as well update the repo, you'll have to adjust the workflow files in the .github
directory and update the note in the readme. CI should catch this stuff now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to 1.21 👍
kvstore/simplemap/simplemap.go
Outdated
Key []byte | ||
} | ||
|
||
func (e *InvalidKeyError) Error() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some godoc comments similar to the badger KVStore ones (copy paste will probably be enough with minor changes) to all the functions and structs in here.
kvstore/simplemap/simplemap_test.go
Outdated
"testing" | ||
) | ||
|
||
func TestSimpleMap(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file? Is this not covered in simplemap/kvstore_test.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it because it was part of the former removed SimpleMap, I only adapted it to this version.
But I guess you are right, the kvstore_test should already cover that. I removed the file again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muXxer Overall love the PR! Thanks for addresses the comments before I did a review.
Left some comments, mostly around godoc comments - I think its better to have them even on non-exported functions just for readability.
Otherwise love the direction this is going in. As @Olshansk one of my goals with this repo is to expand the maps. I will have a look into your KVStore
interface and see what I can do!
To give some context I want to make this a k-ary
tree eventually where the user can decide which k
they desire. Having multiple maps as submodules like how you have done with our badger
map is going to be a huge benefit. I will work on adding support for more and more over time.
CI should run on these commits now so lets see if removing your "go mod magic" works as is. However if not, I will open a PR after the comments have been addressed here and we can merge that one in, but lets give it a go first.
If you have any other requests or PRs please open issues/PRs and we can work on them! Want to see this tree get some more adoption in the industry!
@muXxer Wanted to bump and see if you're still interesting in pushing forward with this PR? |
@muXxer I have been putting some thought into this and can tackle it after Christmas if there isn't a rush on your end. |
Hello! 👋
I don't know if that is the best way to do it, and if you like the change at all, but this PR is trying to get rid of the badger dependency for users that don't need the badger KVStore, by moving the badger implementation to a new module called "github.com/pokt-network/smt/kvstore".
This dependency was introduced in #19